home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre3.z / postgre3 / src / lib / H / tmp / fstack.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  3.5 KB  |  177 lines

  1. /*
  2.  * fstack.h --
  3.  *    Fixed format stack definitions.
  4.  *
  5.  * Note:
  6.  *    Fixed format stacks assist in the construction of FIFO stacks of
  7.  *    fixed format structures.  Structures which are to be stackable
  8.  *    should contain a FixedItemData component.  A stack is initilized
  9.  *    with the offset of the FixedItemData component of the structure
  10.  *    it will hold.  By doing so, push and pop operations are simplified
  11.  *    for the callers.  All references to stackable items are pointers
  12.  *    to the base of the structure instead of pointers to the
  13.  *    FixedItemData component.
  14.  *
  15.  * Identification:
  16.  *    $Header: /private/postgres/src/lib/H/tmp/RCS/fstack.h,v 1.3 1990/08/17 08:54:38 cimarron Exp $
  17.  */
  18.  
  19. #ifndef    FStackIncluded        /* Include this only once */
  20. #define FStackIncluded    1
  21.  
  22. #include "tmp/c.h"
  23.  
  24. /*
  25.  * FixedItem --
  26.  *    Fixed format stackable item chain component.
  27.  *
  28.  * Note:
  29.  *    Structures must contain one FixedItemData component per stack in
  30.  *    which it will be an item.
  31.  */
  32. typedef struct FixedItemData    FixedItemData;
  33. typedef FixedItemData        *FixedItem;
  34.  
  35. struct FixedItemData {
  36.     FixedItem    next;    /* next item or NULL */
  37. };
  38.  
  39. /*
  40.  * FixedStack --
  41.  *    Fixed format stack.
  42.  */
  43. typedef struct FixedStackData {
  44.     FixedItem    top;    /* Top item on the stack or NULL */
  45.     Offset        offset;    /* Offset from struct base to item */
  46.     /* this could be signed short int! */
  47. } FixedStackData;
  48.  
  49. typedef FixedStackData        *FixedStack;
  50.  
  51. /*
  52.  * FixedStackIsValid --
  53.  *    True iff stack is valid.
  54.  */
  55. extern
  56. bool
  57. FixedStackIsValid ARGS((
  58.     FixedStack    stack
  59. ));
  60.  
  61. /*
  62.  * FixedStackInit --
  63.  *    Iniitializes stack for structures with given fixed component offset.
  64.  *
  65.  * Exceptions:
  66.  *    BadArg if stack is invalid pointer.
  67.  */
  68. extern
  69. void
  70. FixedStackInit ARGS((
  71.     FixedStack    stack,
  72.     Offset        offset
  73. ));
  74.  
  75. /*
  76.  * FixedStackPop --
  77.  *    Returns pointer to top structure on stack or NULL if empty stack.
  78.  *
  79.  * Exceptions:
  80.  *    BadArg if stack is invalid.
  81.  */
  82. extern
  83. Pointer
  84. FixedStackPop ARGS((
  85.     FixedStack    stack
  86. ));
  87.  
  88. /*
  89.  * FixedStackPush --
  90.  *    Places structure associated with pointer onto top of stack.
  91.  *
  92.  * Exceptions:
  93.  *    BadArg if stack is invalid.
  94.  *    BadArg if pointer is invalid.
  95.  */
  96. extern
  97. void
  98. FixedStackPush ARGS((
  99.     FixedStack    stack,
  100.     Pointer        pointer
  101. ));
  102.  
  103. /*
  104.  * FixedStackIterate --
  105.  *    Returns count of items in stack.  Iterates through stack items
  106.  *    calling function (if valid) on each.
  107.  *
  108.  * Note:
  109.  *    This is intended for debugging use only.
  110.  *
  111.  * Exceptions:
  112.  *    BadArg if stack is invalid.
  113.  */
  114. extern
  115. Count
  116. FixedStackIterate ARGS((
  117.     FixedStack    stack,
  118.     void        (*function) ARGS((Pointer pointer))
  119. ));
  120.  
  121. /*
  122.  * FixedStackContains --
  123.  *    True iff ordered stack contains given element.
  124.  *
  125.  * Note:
  126.  *    This is inefficient.  It is intended for debugging use only.
  127.  *
  128.  * Exceptions:
  129.  *    BadArg if stack is invalid.
  130.  *    BadArg if pointer is invalid.
  131.  */
  132. extern
  133. bool
  134. FixedStackContains ARGS((
  135.     FixedStack    stack,
  136.     Pointer        pointer
  137. ));
  138.  
  139. /*
  140.  * FixedStackGetTop --
  141.  *    Returns pointer to top structure of a stack.  This item is not poped.
  142.  *
  143.  * Note:
  144.  *    This is not part of the normal stack interface.  It is intended for
  145.  *     debugging use only.
  146.  *
  147.  * Exceptions:
  148.  *    BadArg if stack is invalid.
  149.  */
  150. extern
  151. Pointer
  152. FixedStackGetTop ARGS((
  153.     FixedStack    stack
  154. ));
  155.  
  156. /*
  157.  * FixedStackGetNext --
  158.  *    Returns pointer to next structure after pointer of a stack.
  159.  *
  160.  * Note:
  161.  *    This is not part of the normal stack interface.  It is intended for
  162.  *     debugging use only.
  163.  *
  164.  * Exceptions:
  165.  *    BadArg if stack is invalid.
  166.  *    BadArg if pointer is invalid.
  167.  *    BadArg if stack does not contain pointer.
  168.  */
  169. extern
  170. Pointer
  171. FixedStackGetNext ARGS((
  172.     FixedStack    stack,
  173.     Pointer        pointer
  174. ));
  175.  
  176. #endif    /* !defined(FStackIncluded) */
  177.